I am trying to write a script that takes a module and 2 baselines to show differences between them. I've been able to check regular text but now I'm trying to check to see if a table that exists in one baseline is also in a previous baseline. I am finding that my function is telling me that a table is new even if it did exist in the earlier version. Does anyone know of a way to check for the existence of a particular table object in a baseline? Here is the code I currently have:
bool isNewTable(int nAbsNum, Module bm) {
bool isNew = false;
Object o1 = object(nAbsNum, bm);
if (null(o1)) {
isNew = true;
infoBox("Table " nAbsNum " is new");
}
return isNew;
}
To call the function, I am passing the absolute number of the table (which I'm getting from the newer baseline) and the older baseline module. If I find that the table is not new, my next step will be to check if it has changed in any way (rows/cols added or deleted, cell contents changed).
Chris Cote
Chris Cote chrscote - Fri Sep 30 11:25:54 EDT 2016 |
Re: Creating difference script - checking tables look in help to find how to not show table cells then compare -- this would be easiest approach.
You could check for tale object for loop construct that uses entire keyword. |
Re: Creating difference script - checking tables You should not use the object function to locate the objects in the module. Instead cache the objects in a skip like so:
Skip sk = create();
Object o; for o in entire myBaseline do { int nr = o."Absolute Number"; put (sk, nr, o); }
for o in entire myModule do {
bool isTable = table o;
if (!isTable) continue;
bool bSoftDeleted = isDeleted o;
int nr = o."Absolute Number";
Object oBase = null;
bool bExistsinBaseline = find(sk, nr, oBase);
bool bDeletedInBaseline = (null oBase) ? false : (isDeleted oBase)
}
The object function does respect the current display set (usually table heads invisible), which is not what you want for a compare. You can check if an object is a table by the bool table(Object) perm Regards, Mathias |
Re: Creating difference script - checking tables Mathias Mamsch - Sat Oct 01 09:49:53 EDT 2016 You should not use the object function to locate the objects in the module. Instead cache the objects in a skip like so:
Skip sk = create();
Object o; for o in entire myBaseline do { int nr = o."Absolute Number"; put (sk, nr, o); }
for o in entire myModule do {
bool isTable = table o;
if (!isTable) continue;
bool bSoftDeleted = isDeleted o;
int nr = o."Absolute Number";
Object oBase = null;
bool bExistsinBaseline = find(sk, nr, oBase);
bool bDeletedInBaseline = (null oBase) ? false : (isDeleted oBase)
}
The object function does respect the current display set (usually table heads invisible), which is not what you want for a compare. You can check if an object is a table by the bool table(Object) perm Regards, Mathias
Mathias, I also have another question... Since I've only be working with DOORS scripting for a short time, how do you get the baseline object for myBaseline? How would any function know which module you're getting the baseline from? Sorry if this seems like a trivial question, but I've never had the opportunity to work with DXL before and I'm currently just using code that already existed before I started this project.
Chris Cote |
Re: Creating difference script - checking tables chrscote - Mon Oct 03 08:04:28 EDT 2016
Mathias, I also have another question... Since I've only be working with DOORS scripting for a short time, how do you get the baseline object for myBaseline? How would any function know which module you're getting the baseline from? Sorry if this seems like a trivial question, but I've never had the opportunity to work with DXL before and I'm currently just using code that already existed before I started this project.
Chris Cote Regarding your first question: the "find" function of the skip list has an "out" parameter, which will set the oBase to the value that has been found inside the skip list. If oBase is still null after the find then obviously the object was not found inside the baseline. You could have of course also checked for "bExistsinBaseline" since find will also return false, if no match was found. --> Check the DXL manual for Skip list usage. Regarding your second question: Objects in DXL are always bound to an open Module. Since we iterate over the myBaseline Module in the first loop, all the objects we put in the skip list are from the baseline module. You need to open the baseline with the Module load(ModuleVersion) perm. Another hint: Some functions in DXL rely on the "current" Module, which can be pretty confusing. Most of the time there is another version of those functions, where you can explicitly tell the function which module you are referencing. Example: Object o1 = object 13 // refers to the current module Object o2 = object (13, myModule) // refers to myModule I suggest to always use the explicit versions, since the current Module can change unexpectedly under certain circumstances. Also search the forum for "current" module to find more info. Regards, Mathias |